Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add new migration guide to v12 documentation that describes how… #41828

Closed

Conversation

aikithoughts
Copy link
Contributor

… to migrate older localization ids to new ones

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

n/a

Issue Number: N/A

What is the new behavior?

New content that describes how to migrate legacy localization ids to new ones.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@google-cla google-cla bot added the cla: yes label Apr 27, 2021
@pullapprove pullapprove bot requested a review from jelbourn April 27, 2021 05:42
@aikithoughts aikithoughts added comp: docs target: rc This PR is targeted for the next release-candidate labels Apr 27, 2021
@ngbot ngbot bot modified the milestone: Backlog Apr 27, 2021
@mary-poppins
Copy link

You can preview c59b3f1 at https://pr41828-c59b3f1.ngbuilds.io/.

Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together, @aikidave


`npx localize-migrate --files=*.xlf --mapFile=messages.json`

You now have a list of legacy localization IDs and new IDs, which you can use to update your application.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should actually be part of the previous step. I.e. after you have run localize-extract you now have a list of legacy IDs (the mapfile) that can be used to update the IDs in your translation files.

After running localize-migrate your translation files should now have been updated to use the new IDs. There should be nothing more to do on the application side.

aio/content/guide/migration-legacy-message-id.md Outdated Show resolved Hide resolved

Angular version 12 introduces tooling to help you migrate any existing localization ids to ids that use the latest algorithms.

You have two options for migrating legacy IDs. The first method locates existing IDs, creates new IDs, and replaces the old IDs. The second method is for cases custom localization processes, such as where your localization IDs are not stored in the Angular application. Use this second method if you store your IDs in a database. This method locates legacy IDs and then creates a set of new IDs that you can then use to replace the old ones.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only difference (really) between the two solutions is that the first (and by far the most common) will be to use the CLI to locate existing IDs. The other solution is to use the standalone binary localize-extract to locate the existing IDs.

Both use the same second step, which is to run localize-migrate to update translation files.


## What this migration does

Angular version 12 introduces tooling to help you migrate any existing localization ids to ids that use the latest algorithms.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since v11, all new projects use the modern IDs by default.
Also any use of $localize in application code also uses the moden ID format.
Further, some projects use custom IDs (the set the ID for each translation manually themselves). That being said any legacy ICU messages will not have custom IDs and will need to be migrated.

So, strictly, this migration might not be necessary. Or at least when describing it we should be clear that we only need to migrate "legacy" IDs rather than all existing ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this clarification, @petebacondarwin !

@mary-poppins
Copy link

You can preview dbb83c9 at https://pr41828-dbb83c9.ngbuilds.io/.

Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. A few more fixups needed.


Angular version 11 introduced a new format for localization IDs. These new IDs are more robust the previous, legacy format. However, applications created before version 11 still used the legacy format for these IDs.

With the release of Angular version 12, you now how tools available to help you migrate any existing localization ids to ids that use the latest algorithms.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
With the release of Angular version 12, you now how tools available to help you migrate any existing localization ids to ids that use the latest algorithms.
With the release of Angular version 12, you now have tools available to help you migrate any existing localization IDs to IDs that use the latest algorithms.


`ng extract-i18n --format=legacy-migrate`

After running this command, you have a list of legacy localization IDs and new IDs, which you can use to update your application.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After running this command, you have a list of legacy localization IDs and new IDs, which you can use to update your application.
After running this command, you have a migration file (`messages.json`) containing a mapping between legacy localization IDs and new IDs, which you can use to update your application.


## Migrate legacy IDs using `localize-extract`

To migrate legacy localization IDs using `localize-extract`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

Suggested change
To migrate legacy localization IDs using `localize-extract`:
If you are not using the Angular CLI, then you can migrate legacy localization IDs using `localize-extract`:


`npx localize-extract --format=legacy-migrate --source=./path/to/bundles --outputPath=./`

In this command, `./path/to/bundles/` represents the path to your localization files. You can set the `outputPath` parameter to any directory in your system.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this command, `./path/to/bundles/` represents the path to your localization files. You can set the `outputPath` parameter to any directory in your system.
In this command, `./path/to/bundles/` represents the path to your distributable files. You can set the `outputPath` parameter to any directory in your system.

The bundles will be the generated JavaScript from whatever build tooling they are using.


In this command, `./path/to/bundles/` represents the path to your localization files. You can set the `outputPath` parameter to any directory in your system.

After running this command, you have a list of legacy localization IDs and new IDs, which you can use to update your application.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After running this command, you have a list of legacy localization IDs and new IDs, which you can use to update your application.
After running this command, you have a migration file (`messages.json`) containing a mapping between legacy localization IDs and new IDs, which you can use to update your application.

aio/content/guide/migration-legacy-message-id.md Outdated Show resolved Hide resolved

1. Run the `npx localize-extract` command.

`npx localize-extract --format=legacy-migrate --source=./path/to/bundles --outputPath=./`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The outputPath has to actually be a path to the file, not the directory. So

Suggested change
`npx localize-extract --format=legacy-migrate --source=./path/to/bundles --outputPath=./`
`npx localize-extract --format=legacy-migrate --source=./path/to/bundles --outputPath=./messages.json`


## What this migration does

Angular version 11 introduced a new format for localization IDs. These new IDs are more robust the previous, legacy format. However, applications created before version 11 still used the legacy format for these IDs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Angular version 11 introduced a new format for localization IDs. These new IDs are more robust the previous, legacy format. However, applications created before version 11 still used the legacy format for these IDs.
Angular version 11 introduced a new format for localization IDs. These new IDs are more robust than the previous, legacy format. However, applications created before version 11 still used the legacy format for these IDs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @ahasall !


## Why is this migration necessary

The Angular translation system works by matching a message ID to a translated message in a different language. One option for creating these IDs is to have the translation system generate them for you. Previous algorithms that created these IDs have, over time, become fragile to formatting changes. The new algorithms are much more robust. This migration system helps you improve application stability by creating new legacy IDs that you can add to your application.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the last sentence, I'm not sure that "application stability" is the correct term. Migrating to the new system makes it more future-proof, because they won't have to migrate later when we remove the new format. It also means that the IDs will change less frequently.

{
"url": "guide/migration-legacy-message-id",
"title": "Migration: Legacy Localization IDs",
"tooltip": "Learn how to migrate older IDs for localization to new, more stable ones."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

older -> old. I don't think that we have any older ID algorithms than the ones we're migrating away from.


With the release of Angular version 12, you now how tools available to help you migrate any existing localization ids to ids that use the latest algorithms.

You have two options for migrating legacy IDs. The first method uses the Angular CLI to locate legacy IDs in your application. The second method uses a standalone application, `localize-extract` to locate the legacy IDs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You have two options for migrating legacy IDs. The first method uses the Angular CLI to locate legacy IDs in your application. The second method uses a standalone application, `localize-extract` to locate the legacy IDs.
You have two options for migrating legacy IDs. The first method uses the Angular CLI to locate legacy IDs in your application. The second method uses a standalone application, `localize-extract`, to locate the legacy IDs.


## What this migration does

Angular version 11 introduced a new format for localization IDs. These new IDs are more robust the previous, legacy format. However, applications created before version 11 still used the legacy format for these IDs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Angular version 11 introduced a new format for localization IDs. These new IDs are more robust the previous, legacy format. However, applications created before version 11 still used the legacy format for these IDs.
Angular version 11 introduced a new format for localization IDs. These new IDs are more robust the previous legacy format. However, applications created before version 11 still used the legacy format for these IDs.

You can also specify other formats in the `files` parameter, such as `*.xmb`.
</div>

## Why is this migration necessary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Why is this migration necessary
## Why this migration is necessary

Moved word for better flow

@TeriGlover
Copy link
Contributor

TeriGlover commented Apr 27, 2021 via email


## Why is this migration necessary

The Angular translation system works by matching a message ID to a translated message in a different language. One option for creating these IDs is to have the translation system generate them for you. Previous algorithms that created these IDs have, over time, become fragile to formatting changes. The new algorithms are much more robust. This migration system helps you improve application stability by creating new legacy IDs that you can add to your application.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it would be useful to move the content from "why is this migration necessary" higher up so that people more quickly know why they should care about this migration in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following the pattern of previous migration guides, but I agree. I'll put this section ahead of "What this migration does"

Copy link
Contributor Author

@aikithoughts aikithoughts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback!


## What this migration does

Angular version 11 introduced a new format for localization IDs. These new IDs are more robust the previous, legacy format. However, applications created before version 11 still used the legacy format for these IDs.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @ahasall !

aio/content/guide/migration-legacy-message-id.md Outdated Show resolved Hide resolved

## Why is this migration necessary

The Angular translation system works by matching a message ID to a translated message in a different language. One option for creating these IDs is to have the translation system generate them for you. Previous algorithms that created these IDs have, over time, become fragile to formatting changes. The new algorithms are much more robust. This migration system helps you improve application stability by creating new legacy IDs that you can add to your application.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following the pattern of previous migration guides, but I agree. I'll put this section ahead of "What this migration does"

@mary-poppins
Copy link

You can preview 2c95e78 at https://pr41828-2c95e78.ngbuilds.io/.

aio/content/guide/migration-legacy-message-id.md Outdated Show resolved Hide resolved
aio/content/guide/migration-legacy-message-id.md Outdated Show resolved Hide resolved

1. Commit the updated files to your source control system.

After you complete the migration, set the Angular Compiler option, `enableI18nLegacyMessageIdFormat`, to `false`. For more information about this option, see [Angular Compiler Options](/guide/angular-compiler-options#enablei18nlegacymessageidformat).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this paragraph is both here and at the bottom of the guide. Should one of them be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because these are two different sections. Folks who are reading one may not read the other.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm aside from other outstanding comments

@mary-poppins
Copy link

You can preview 97d4465 at https://pr41828-97d4465.ngbuilds.io/.

Copy link
Contributor

@TeriGlover TeriGlover left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One overlooked item in editing pass.


</div>

With the release of Angular version 12, you now have how tools available to help you migrate any existing localization IDs to IDs that use the latest algorithms.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
With the release of Angular version 12, you now have how tools available to help you migrate any existing localization IDs to IDs that use the latest algorithms.
With the release of Angular version 12, you now have tools available to help you migrate any existing localization IDs to IDs that use the latest algorithms.

Deleted unnecessary word.

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great @aikidave - thanks for your patience with my confusion over the utility of npx.

aio/content/guide/migration-legacy-message-id.md Outdated Show resolved Hide resolved
aio/content/guide/migration-legacy-message-id.md Outdated Show resolved Hide resolved
aio/content/guide/migration-legacy-message-id.md Outdated Show resolved Hide resolved
aio/content/guide/migration-legacy-message-id.md Outdated Show resolved Hide resolved
aio/content/guide/migration-legacy-message-id.md Outdated Show resolved Hide resolved
aio/content/navigation.json Outdated Show resolved Hide resolved
@petebacondarwin
Copy link
Member

Oh two more things...

  1. Can we add a {@searchKeywords i18n} search keyword tag to help this appear when the user searches for i18n.
  2. Can we try using <code-example> blocks for the command line instructions. In the previews, the code blocks are a bit unclear to me.

E.g.

<code-example language="bash">
ng extract-i18n --format=legacy-migrate
</code-example>

.pullapprove.yml Outdated Show resolved Hide resolved
.pullapprove.yml Outdated Show resolved Hide resolved
@mary-poppins
Copy link

You can preview ed46fe6 at https://pr41828-ed46fe6.ngbuilds.io/.

… to migrate older localization ids to new ones
@aikithoughts aikithoughts added the action: merge The PR is ready for merge by the caretaker label May 3, 2021
@mary-poppins
Copy link

You can preview d9cde61 at https://pr41828-d9cde61.ngbuilds.io/.

@mhevery mhevery closed this in 6d7d659 May 4, 2021
mhevery pushed a commit that referenced this pull request May 4, 2021
… to migrate older localization ids to new ones (#41828)

PR Close #41828
@e-oz
Copy link

e-oz commented May 6, 2021

Thank you, it was really usefull.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker aio: preview cla: yes target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants